<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text">

    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
    <script>
        // input标签
        let input = document.getElementsByTagName('input')[0]
        let ul = document.getElementsByTagName('ul')[0]
        let li = ul.getElementsByTagName('li')[0]
        ul.onmouseenter= function (e) {
            e = e || event
            console.dir(e)
            console.log(e.target)//当前点击的li 触发事件
            console.log(e.currentTarget) //ul
            console.log(e.currentTarget == this)
            e.target.style.background = 'red'
        }
        input.maxLength = 10
        input.onkeydown = function () { //每次按下键盘都会触发事件
            // return false
            // console.log('aa')
            input.value = input.value.trim()
        }
    </script>
</body>

</html>